#ifndef DIALOG_H
#define DIALOG_H

#include <QDialog>
#include <QStandardItemModel>
#include <QDebug>
#include <QSqlQuery>
#include <QTimer>
#include <QMessageBox>
#include <QTableView>
#include <QSqlQueryModel>
#include <QTime>

#include "mainwindow.h"
namespace Ui {
class Dialog;
}

class Dialog : public QDialog
{
    Q_OBJECT

public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();

    void queryTable();
    void setpage_off(int p);
    void setpage_on(int p);

    QString gaintime();




private slots:

    void switchuicallback();

    void deal_key();

    void dialog_init();

    void sql_insert_data(QString type, QString message);

    void on_Button_open_light_clicked();

    void on_Button_go_kitchen__clicked();

    void on_Button_go_livingroom_clicked();

    void on_Button_bed_room2_clicked();

    void on_Button_bed_room1_clicked();

    void on_pushButton_record_clicked();

    void on_pushButton_return_clicked();

    void on_pushButton_query_clicked();

    void on_Button_close_light_clicked();

    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

private:
    Ui::Dialog *ui;
    QDateTime current_date_time;
    QString current_time;
    QSqlQueryModel sqlmodel ; //保存结果集

    QString tablename;


    bool kitchen_light,livingroom_light,bed_room2_light,bed_room1_light;

    char KbdStatus=0;//获取按键状态
    int Last_key_value;
    QTimer *KbdScanTimer;
    QTimer *SwitchUITimer;

    QImage Image_lampson;
    QImage Image_lampsoff;
    QPixmap pixmap_lampson;
    QPixmap pixmap_lampsoff;
    QPixmap fitpixmap_lampson;
    QPixmap fitpixmap_lampsoff;

};

#endif // DIALOG_H
